<?php
/**
 * 
 */

/**
 * 
 */

/**
 * Edit Types for updating project edits
 *
 * @author anthony
 */
class ProjectEditType {
    //Tags
    const AddTag = 0;
    const DelTag = 1;
    //Sites
    const AddSite = 2;
    const DelSite = 3;
    //Blogs
    const AddBlog = 4;
    const DelBlog = 5;
    //Docs
    const AddDocs = 6;
    const DelDocs = 7;
    //Twitter
    const AddTwitter = 8;
    const DelTwitter = 9;
    const ChangeActiveTwitter = 10;
    //Maintainers
    const AddMaintainer = 11;
    const DelMaintainer = 12;
    const changeLeader = 13;
    //RSS
    const AddRSS = 14;
    const DelRSS = 15;
    //Data Update
    const ChangeSettings = 16;
    
    //Tags
    const AdminAddTag = 900;
    const AdminDelTag = 901;
    //Sites
    const AdminAddSite = 902;
    const AdminDelSite = 903;
    //Blogs
    const AdminAddBlog = 904;
    const AdminDelBlog = 905;
    //Docs
    const AdminAddDocs = 906;
    const AdminDelDocs = 907;
    //Twitter
    const AdminAddTwitter = 908;
    const AdminDelTwitter = 909;
    const AdminChangeActiveTwitter = 910;
    //Maintainers
    const AdminAddMaintainer = 911;
    const AdminDelMaintainer = 912;
    const AdminchangeLeader = 913;
    //RSS
    const AdminAddRSS = 914;
    const AdminDelRSS = 915;
    //Data Update
    const AdminChangeSettings = 16;
    
    public static function resolveTypeToText($type) {
	if($type == ProjectEditType::AddTag) {
	    return 'Added Tag';
	} elseif($type == ProjectEditType::DelTag) {
	    return 'Deleted Tag';
	} elseif($type == ProjectEditType::AddSite) {
	    return 'Added Site';
	} elseif($type == ProjectEditType::DelSite) {
	    return 'Deleted Site';
	} elseif($type == ProjectEditType::AddBlog) {
	    return 'Added Blog';
	} elseif($type == ProjectEditType::DelBlog) {
	    return 'Deleted Blog';
	} elseif($type == ProjectEditType::AddDocs) {
	    return 'Added Doc Link';
	} elseif($type == ProjectEditType::DelDocs) {
	    return 'Deleted Doc Link';
	} elseif($type == ProjectEditType::AddTwitter) {
	    return 'Added Twitter';
	} elseif($type == ProjectEditType::DelTwitter) {
	    return 'Deleted Twitter';
	} elseif($type == ProjectEditType::ChangeActiveTwitter) {
	    return 'Changed Active Twitter';
	} elseif($type == ProjectEditType::AddMaintainer) {
	    return 'Added Maintainer';
	} elseif($type == ProjectEditType::DelMaintainer) {
	    return 'Deleted Maintainer';
	} elseif($type == ProjectEditType::changeLeader) {
	    return 'Changed Lead Maintainer';
	} elseif($type == ProjectEditType::AddRSS) {
	    return 'Added RSS Feed';
	} elseif($type == ProjectEditType::DelRSS) {
	    return 'Deleted RSS Feed';
	} elseif($type == ProjectEditType::ChangeSettings) {
	    return 'Changed Project Settings';
	} elseif($type == ProjectEditType::AdminAddTag) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Added Tag';
	} elseif($type == ProjectEditType::AdminDelTag) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Deleted Tag';
	} elseif($type == ProjectEditType::AdminAddSite) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Added Site';
	} elseif($type == ProjectEditType::AdminDelSite) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Deleted Site';
	} elseif($type == ProjectEditType::AdminAddBlog) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Added Blog';
	} elseif($type == ProjectEditType::AdminDelBlog) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Deleted Blog';
	} elseif($type == ProjectEditType::AdminAddDocs) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Added Doc Link';
	} elseif($type == ProjectEditType::AdminDelDocs) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Deleted Doc Link';
	} elseif($type == ProjectEditType::AdminAddTwitter) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Added Twitter';
	} elseif($type == ProjectEditType::AdminDelTwitter) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Deleted Twitter';
	} elseif($type == ProjectEditType::AdminChangeActiveTwitter) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Changed Active Twitter';
	} elseif($type == ProjectEditType::AdminAddMaintainer) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Added Maintainer';
	} elseif($type == ProjectEditType::AdminDelMaintainer) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Deleted Maintainer';
	} elseif($type == ProjectEditType::AdminchangeLeader) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Changed Lead Maintainer';
	} elseif($type == ProjectEditType::AdminAddRSS) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Added RSS Feed';
	} elseif($type == ProjectEditType::AdminDelRSS) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Deleted RSS Feed';
	} elseif($type == ProjectEditType::AdminChangeSettings) {
	    return '<span class="admin_edit_span">ADMIN EDIT</span> Changed Project Settings';
	} else {
	    return false;
	}
    }
    
    public static function resolveUser($userid) {
	global $UserStash;
	$userid = (int)$userid;
	try {
	    $user =& $UserStash->get($userid);
	    return @$user;
	} catch(InvalidUserException $e) {
	    return false;
	}
    }
    
    public static function resolveTag($tagid) {
	global $TagStash;
	$tagid = (int)$tagid;
	try {
	    $tag =& $TagStash->get($tagid);
	    return $tag;
	} catch(InvalidTagException $e) {
	    return false;
	}
    }
    
    public static function isUserEdit($editType) {
	if($editType == ProjectEditType::AdminAddMaintainer || $editType == ProjectEditType::AddMaintainer || $editType == ProjectEditType::AdminDelMaintainer || $editType == ProjectEditType::DelMaintainer) {
	    return true;
	} else {
	    return false;
	}
    }
    
    public static function isTagEdit($editType) {
	if($editType == ProjectEditType::AdminAddTag || $editType == ProjectEditType::AddTag || $editType == ProjectEditType::AdminDelTag || $editType == ProjectEditType::DelTag) {
	    return true;
	} else {
	    return false;
	}
    }
}

?>
